home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-170 dbase 10 for windows / 1.ima / SAMPLES.PAK / LINKLIST.PRG < prev    next >
Text File  |  1993-07-26  |  2KB  |  65 lines

  1. *******************************************************************************
  2. *  PROGRAM:      Linklist.prg
  3. *
  4. *  WRITTEN BY:   Borland Late Night Crew
  5. *
  6. *  DATE:         6/93
  7. *
  8. *  UPDATED:
  9. *
  10. *  VERSION:      Alpha α
  11. *
  12. *  DESCRIPTION:  This program creates a simple linked list of integers
  13. *                from 1 to 10.  Each link in the chain is an instance of the
  14. *                MyList class, which has 2 properties -- value, and next.
  15. *                After the list is created, the function ShowList steps
  16. *                through the list and shows all the links that have been
  17. *                created.
  18. *
  19. *  PARAMETERS:   None
  20. *
  21. *  CALLS:        None
  22. *
  23. *  USAGE:        DO Linklist
  24. *
  25. *******************************************************************************
  26.  
  27. * a simple xbase linked-list:
  28.  
  29. set talk off
  30. * beginning of the list
  31. x = new mylist()     &&  instantiation
  32. y = x  && y is a temporary reference for stepping through the list
  33. for i = 1 to 10
  34.    y.val = i
  35.    y.next = new mylist() && create a new link
  36.    y = y.next
  37. next
  38. do showlist
  39.  
  40.  
  41. * class definition for mylist
  42. *******************************************************************************
  43. class mylist
  44. *******************************************************************************
  45.    this.val = 0
  46.    this.next = 0
  47. endclass
  48.  
  49.  
  50.  
  51.  
  52. *******************************************************************************
  53. function showlist
  54. *   Displays the linked list created in the main program
  55. *******************************************************************************
  56.    y = x  && start at the beginning of the list
  57.    do while (.not. empty(y))
  58.       ? y.val
  59.       y = y.next
  60.    enddo
  61.  
  62.  
  63.  
  64. **************************** End of Linklist.prg ******************************
  65.